//
//  ChartViewController.m
//  SheShiDu
//
//  Created by 泉  姜 on 16/6/22.
//  Copyright © 2016年 单剑秋. All rights reserved.
//

#import "ChartViewController.h"
#import "ChartCell.h"

#define HEIGHT self.view.frame.size.height
#define WIDTH self.view.frame.size.width
@interface ChartViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong)UITableView *tableView;
@property (nonatomic, strong)NSMutableArray *imgArr;
@property (nonatomic, strong)NSMutableArray *titleArr;

@end

@implementation ChartViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self backItem];
    
    [self createTableView];
}

- (void)backItem
{
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(left:)];
}

- (void)left:(UIBarButtonItem *)left
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)createTableView
{
    self.imgArr = [[NSMutableArray array] init];
    
    for (int i = 1; i < 3; i++) {
        NSString *result = [NSString stringWithFormat:@"R%d", i];
        [_imgArr addObject:[UIImage imageNamed:result]];
    }
    
    self.titleArr = [[NSMutableArray array] init];
    _titleArr = [NSMutableArray arrayWithObjects:@"CAD", @"效果图", nil];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, self.view.bounds.size.height - 49 - 64) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    
    [_tableView registerClass:[ChartCell class] forCellReuseIdentifier:@"cell"];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ChartCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    [cell.imgView setImage:[_imgArr objectAtIndex:indexPath.item]];
    [cell.titleLabel setText:[_titleArr objectAtIndex:indexPath.item]];
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return (self.view.bounds.size.height - 49 - 64) / 2;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
